#ifndef UHEADERVIEW_H
#define UHEADERVIEW_H

#include "utkwidget_export.h"

#include <QHeaderView>

class UHeaderViewPrivate;
class UTKWIDGET_EXPORT UHeaderView : public QHeaderView
{
    Q_OBJECT
public:
    explicit UHeaderView(Qt::Orientation orientation, QWidget* parent = nullptr, int checkBoxColumn = -1);
    ~UHeaderView() override;

    void updateContent();

    void setCheckColumnIndex(int index);

    int checkColumnIndex();

    void updateHeaderViewSection(int logicalIndex);

    Qt::CheckState checkState() const;

    void setCheckState(Qt::CheckState state);

    void setIndexWidget(int index, QWidget* item);

    const QMap<int, QWidget*> &headerItemMap();

signals:
    void stateChanged(const Qt::CheckState &state, int logicalIndex);

public slots:
    void onSectionResized(int logicalIndex, int oldSize, int newSize);

protected:
    void initStyleOption(QStyleOptionButton* option) const;
    void paintSection(QPainter* painter, const QRect &rect, int logicalIndex) const override;
    void paintSectionContent(QPainter* painter, const QRect &rect, int logicalIndex) const;
    void mousePressEvent(QMouseEvent* e) override;
    void mouseMoveEvent(QMouseEvent* e) override;
    void mouseReleaseEvent(QMouseEvent* e) override;

private:
    Q_DISABLE_COPY(UHeaderView)
    Q_DECLARE_PRIVATE(UHeaderView)

    UHeaderViewPrivate* d_ptr = Q_NULLPTR;
};

#endif // UHEADERVIEW_H
